package com.mall.action;

import com.mall.bean.ItemCat;
import com.mall.bean.ItemGoods;
import com.mall.service.CatsService;
import com.mall.service.ItemGoodsService;
import com.mall.uitl.JsonUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

//import javax.jws.Oneway;
import java.util.List;

/**
 * @author lwd1513
 * @date 2022-04-25 10 06
 * discription
 */
@RestController
@RequestMapping("/Index/CatsController2")
public class CatsController2 {

    @Autowired
    private CatsService catsService;

    @Autowired
    private ItemGoodsService itemGoodsService;

    @RequestMapping("/getMoreCatGoods")
    public JsonUtil getMoreCatGoods() {
        List<ItemCat> catGoodsList = catsService.getMoreCatGoods();
        JsonUtil jsonUtil = new JsonUtil();
        jsonUtil.setData(catGoodsList);
        return jsonUtil;
    }

    @RequestMapping("/getCatGoodsList")
    public JsonUtil getCatGoodsList() {
        List<ItemCat> catGoodsList = catsService.getCatGoodsList();
        JsonUtil jsonUtil = new JsonUtil();
        jsonUtil.setData(catGoodsList);
        return jsonUtil;
    }

    @RequestMapping("/getMoreGoodsByCatId/{catId}")
    public JsonUtil getMoreGoodsByCatId(@PathVariable("catId") String catId) {
        List<ItemGoods> itemGoods = itemGoodsService.getMoreGoodsByCatId(catId);
        JsonUtil jsonUtil = new JsonUtil();
        jsonUtil.setData(itemGoods);
        return jsonUtil;
    }
}
